package com.api.gbhg.zengping.dao;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.conn.RecordSetTrans;

/**
 * @program: gbhg-oa
 * @author: Mr.zeng
 * @create: 2020-12-30 16:35
 **/
public class JobAdministrationDao implements Dao{
    public static final Logger LOGGER = LoggerFactory.getLogger("gbhg");

    @Override
    public RecordSetTrans getSBInfo(String lcStatus, Integer pageNum, Integer pageSize,String requestId){
        RecordSetTrans rst=new RecordSetTrans();
        StringBuffer sb=new StringBuffer();
        //String sql="SELECT lcjlsqjlid,t.id,xmmin,v.sbdw,sbks,v.fzr,yszje,ygzffrs,zwgz,jbgz,gzxjt,shxbt,gxjt,nzycxjj,tqjt,yxwxnxjbc,jswmj,jhsyj,lsbt,dsznfmjlf FROM uf_jingfei_version v,uf_hgzzxzrygzjbtjfbb t,uf_hgzzxzrygzjbtjfbb_dt1 t1  WHERE t.requestId=v.lcjlsqjlid AND mainid=t.id\n";

        String sql="select lcjlsqjlid,t.id,xmmin,v.sbdw,sbks,v.fzr,yszje,sum(ygzffrs)ygzffrs,sum(zwgz)zwgz,sum(jbgz)jbgz,sum(gzxjt)gzxjt,\n" +
                "sum(shxbt)shxbt,sum(gxjt)gxjt,sum(nzycxjj)nzycxjj,sum(tqjt)tqjt,sum(yxwxnxjbc)yxwxnxjbc,sum(jswmj)jswmj,sum(jhsyj)jhsyj,sum(lsbt)lsbt,sum(dsznfmjlf)dsznfmjlf\n" +
                "from uf_jingfei_version v,uf_hgzzxzrygzjbtjfbb t,uf_hgzzxzrygzjbtjfbb_dt1 t1 \n" +
                "WHERE t.requestId=v.lcjlsqjlid AND mainid=t.id";
        try {
            sb.append(sql);
            String group=" group by lcjlsqjlid,t.id,xmmin,v.sbdw,sbks,v.fzr,yszje ";
            sb=PropertyManagementCostDao.limitSize(rst,sb,lcStatus,pageNum,pageSize,group,requestId);
            LOGGER.info("===========离退休人员津贴核批列表数据查询==================="+sb.toString());
            rst.executeSql(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
            rst.rollback();
        }
        return rst;
    }
    public RecordSetTrans getSBInfo(String requestId){
        RecordSetTrans rst=new RecordSetTrans();
        StringBuffer sb=new StringBuffer();
        String sql="select lcjlsqjlid,t.id,xmmin,v.sbdw,sbks,v.fzr,yszje,sum(ygzffrs)ygzffrs,sum(zwgz)zwgz,sum(jbgz)jbgz,sum(gzxjt)gzxjt,\n" +
                "sum(shxbt)shxbt,sum(gxjt)gxjt,sum(nzycxjj)nzycxjj,sum(tqjt)tqjt,sum(yxwxnxjbc)yxwxnxjbc,sum(jswmj)jswmj,sum(jhsyj)jhsyj,sum(lsbt)lsbt,sum(dsznfmjlf)dsznfmjlf\n" +
                "from uf_jingfei_version v,uf_hgzzxzrygzjbtjfbb t,uf_hgzzxzrygzjbtjfbb_dt1 t1 \n" +
                "WHERE t.requestId=v.lcjlsqjlid AND mainid=t.id";
        try {
            sb.append(sql);
            String group=" group by lcjlsqjlid,t.id,xmmin,v.sbdw,sbks,v.fzr,yszje ";
            sb=PropertyManagementCostDao.limitSize(sb,group,requestId);
            LOGGER.info("离退休人员津贴核批列表数据查询------------->"+sb.toString());
            rst.executeSql(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
            rst.rollback();
        }
        return rst;
    }

    /**
     * 海关在职行政人员核批列表查询条数   uf_wygljfbb
     * @param lcztz
     * @return
     */
    @Override
    public RecordSetTrans getSBInfoCount(String lcztz,String tableName,String requestId){
        RecordSetTrans rts=new RecordSetTrans();
        StringBuffer sb=new StringBuffer();
        String sql="SELECT count(1)num FROM (select lcjlsqjlid,t.id,xmmin,v.sbdw,sbks,v.fzr,sum(yszje)yszje,count(ygzffrs)ygzffrs,sum(zwgz)zwgz,sum(jbgz)jbgz,sum(gzxjt)gzxjt,\n" +
                "sum(shxbt)shxbt,sum(gxjt)gxjt,sum(nzycxjj)nzycxjj,sum(tqjt)tqjt,sum(yxwxnxjbc)yxwxnxjbc,sum(jswmj)jswmj,sum(jhsyj)jhsyj,sum(lsbt)lsbt,sum(dsznfmjlf)dsznfmjlf\n" +
                "from uf_jingfei_version v,uf_hgzzxzrygzjbtjfbb t,uf_hgzzxzrygzjbtjfbb_dt1 t1 \n" +
                "WHERE t.requestId=v.lcjlsqjlid AND mainid=t.id";

        sb.append(sql);
        try {
            if("3".equals(lcztz)){
                sb.append(" AND lcztz="+lcztz+" AND t.requestId IN("+requestId+")");
            }else {
                sb.append(" AND lcztz<> 3 AND t.requestId IN("+requestId+")");
            }
            sb.append(" group by lcjlsqjlid,t.id,xmmin,v.sbdw,sbks,v.fzr)t");
            LOGGER.info("===========海关在职行政人员核批列表查询条数==================="+sb.toString());
            rts.executeQuery(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return rts;
    }
    public RecordSetTrans getSBInfoCount(String tableName,String requestId){
        RecordSetTrans rts=new RecordSetTrans();
        StringBuffer sb=new StringBuffer();
        String sql="SELECT count(1)num FROM (select lcjlsqjlid,t.id,xmmin,v.sbdw,sbks,v.fzr,sum(yszje)yszje,count(ygzffrs)ygzffrs,sum(zwgz)zwgz,sum(jbgz)jbgz,sum(gzxjt)gzxjt,\n" +
                "sum(shxbt)shxbt,sum(gxjt)gxjt,sum(nzycxjj)nzycxjj,sum(tqjt)tqjt,sum(yxwxnxjbc)yxwxnxjbc,sum(jswmj)jswmj,sum(jhsyj)jhsyj,sum(lsbt)lsbt,sum(dsznfmjlf)dsznfmjlf\n" +
                "from uf_jingfei_version v,uf_hgzzxzrygzjbtjfbb t,uf_hgzzxzrygzjbtjfbb_dt1 t1 \n" +
                "WHERE t.requestId=v.lcjlsqjlid AND mainid=t.id";

        sb.append(sql);
        try {

            sb.append(" AND t.requestId IN("+requestId+")");
            sb.append(" group by lcjlsqjlid,t.id,xmmin,v.sbdw,sbks,v.fzr)t");
            LOGGER.info("海关在职行政人员核批列表查询条数:--------------->"+sb.toString());
            rts.executeQuery(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return rts;
    }

}
